﻿using ALMDDD.AspNetCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;

namespace ALMDDD.Domain.Interfaces
{
    /// <summary>
    /// 仓储接口
    /// </summary>
    /// <typeparam name="Tentity">实体类</typeparam>
    public interface IRepository<Tentity> : IDisposable where Tentity : class
    {
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="tentity"></param>
        void Add(Tentity tentity);
        /// <summary>
        /// 根据id获取对象信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        Tentity GetById(Guid id);
        /// <summary>
        /// 根据条件查询
        /// </summary>
        /// <param name="where">查询条件</param>
        /// <returns></returns>
        Tentity GetMany(Expression<Func<Tentity, bool>> where);
        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="where">查询条件</param>
        /// <param name="paging">分页参数</param>
        /// <returns></returns>
        Tuple<int, int, IEnumerable<Tentity>> GetMany(Expression<Func<Tentity, bool>> where, Paging paging);
        /// <summary>
        /// 获取列表
        /// </summary>
        /// <returns></returns>
        IQueryable<Tentity> GetAll();

        /// <summary>
        /// 根据对象进行修改
        /// </summary>
        /// <param name="obj"></param>
        void Update(Tentity obj);
        /// <summary>
        /// 根据id删除
        /// </summary>
        /// <param name="id"></param>
        void Remove(Guid id);
        /// <summary>
        /// 保存
        /// </summary>
        /// <returns></returns>
        int SaveChanges();




    }
}
